package com.shoute.ai.tools;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.shoute.ai.entity.query.KmArchivesMainQuery;
import com.shoute.ai.entity.secondary.KmArchivesMain;
import com.shoute.ai.service.secondary.KmArchivesMainService;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.stereotype.Component;

import java.util.List;

@RequiredArgsConstructor
@Component
public class FilesTools {

    private final KmArchivesMainService kmArchivesMainService;

    @Tool(description = "根据条件查询文件/档案")
    public List<KmArchivesMain>  queryKmArchivesMain(@ToolParam(description = "查询的条件", required = false) KmArchivesMainQuery kmArchivesMain){

        if(kmArchivesMain == null ){
            return kmArchivesMainService.list();
        }
        LambdaQueryWrapper<KmArchivesMain> wrapper = new LambdaQueryWrapper<KmArchivesMain>()
//                .like(StringUtils.isNotEmpty(kmArchivesMain.getFilingCompany()), KmArchivesMain::getFilingCompany, kmArchivesMain.getFilingCompany())
//                .like(StringUtils.isNotEmpty(kmArchivesMain.getFilingDeptName()), KmArchivesMain::getFilingDeptName, kmArchivesMain.getFilingDeptName())
//                .like(StringUtils.isNotEmpty(kmArchivesMain.getFilingUserName()), KmArchivesMain::getFilingUserName, kmArchivesMain.getFilingUserName())
                .like(StringUtils.isNotEmpty(kmArchivesMain.getArchivesName()), KmArchivesMain::getArchivesName, kmArchivesMain.getArchivesName());
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesNumber()), KmArchivesMain::getArchivesNumber, kmArchivesMain.getArchivesNumber())
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesType()), KmArchivesMain::getArchivesType, kmArchivesMain.getArchivesType())
//                .eq(kmArchivesMain.getArchivesDate()!= null, KmArchivesMain::getArchivesDate, kmArchivesMain.getArchivesDate())
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesYear()), KmArchivesMain::getArchivesYear, kmArchivesMain.getArchivesYear())
//                .eq(kmArchivesMain.getArchivesQuantity() != 0, KmArchivesMain::getArchivesYear, kmArchivesMain.getArchivesYear())
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesPeriod()), KmArchivesMain::getArchivesPeriod, kmArchivesMain.getArchivesPeriod())
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesSecret()), KmArchivesMain::getArchivesSecret, kmArchivesMain.getArchivesSecret())
//                .eq(StringUtils.isNotEmpty(kmArchivesMain.getArchivesClassify()), KmArchivesMain::getArchivesClassify, kmArchivesMain.getArchivesClassify())
//                .between(kmArchivesMain.getArchivesDate() != null, KmArchivesMain::getArchivesDate, kmArchivesMain.getStartTime(), kmArchivesMain.getEndTime())
//                .orderByDesc(KmArchivesMain::getArchivesDate);
        return kmArchivesMainService.list(wrapper);
    }




}
